<template>
  <div id="withdraw">
    <header>
      <i @click="goBack()"></i>
      <div>提现</div>
    </header>
    <img src="../../image/pic_Cash.png" alt="" width='67'>
    <div class='tx'>
      <p>您的账户可提现金额为:</p>
      <i>
        <b>{{money}}</b> 元</i>
    </div>
    <p>请您输入要提现的金额</p>
    <input type="text" placeholder="￥" v-model="obj.amount">
    <input type="text" placeholder="请输入要提现的支付宝账号" v-model="obj.payee_account">
    <a href='javascript:;' class="withdraw" @click="withdraw">提现</a>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        money: '',
        list: [],
        obj: {
          user_id: '',
          payee_account: '',
          amount: '',
          user_money: '',
        }
      }
    },
    components: {

    },
    methods: {
      goBack() {
        this.$router.push({
          path: '/myAccount'
        })
      },
      init() {
        this.obj.user_id = localStorage.getItem("loginMobile");
        this.$api.get(this.$api.baseURLSchool, "/no_page/user?id=" + this.obj.user_id, {}, r => {
          if (r.data.ret == 1) {
            this.money = r.data.info[0].money;
          }
        }, err => {
          console.log(err);
        })
      },
      withdraw() {
        this.obj.user_money = this.money;
        this.$api.post(this.$api.baseURLSchool, "/ali_tixian", this.obj, r => {
          if (r.data.ret == 1) {
            this.money = r.data.money;
            this.$utils._toast('提现成功');
          } else if (r.data.ret == -1) {

            if (r.data.info == 'fail') {
              this.$utils._toast('提现失败');
            } else {
              this.$utils._toast(r.data.errmsg);

            }
          }
        }, err => {
          console.log(err);
        })
      }
    },
    created() {
      this.init()
    },
    mounted() {

    }
  }

</script>
<style lang="scss">


</style>
